package com.zp.qualitypractice.Mvp;

import com.zp.qualitypractice.App;
import com.zp.qualitypractice.Bean.BeanResponse;
import com.zp.qualitypractice.Bean.BeanSplash;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by izp on 2017/4/14.
 */

public class PresenterSplash extends RxPresenter<MvpSplash.View> implements MvpSplash.Presenter {

    @Override
    public void getSplashBean() {
        Disposable disposable = App.getDataCenter().getSplash().getStartImg("","")
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Consumer<BeanResponse<BeanSplash>>() {
                    @Override
                    public void accept(@NonNull BeanResponse<BeanSplash> beanSplashBeanResponse) throws Exception {
                        mView.showSplash(beanSplashBeanResponse.getReturnObject());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {

                    }
                });
        addDisposable(disposable);//为RxPresenter添加订阅管理
    }
}
